package top.whysu.rongcloud.util;

import top.whysu.rongcloud.constant.CodeConstant;
import top.whysu.rongcloud.dto.http.Response;

/**
 * 通用处理响应
 */
public class ResponseUtil {

    public static <T> Response<T> getSuccessResponse(T body) {
        final Response<T> response = new Response<>();
        response.setCode(CodeConstant.Http.SUCCESS);
        response.setMsg("操作成功！");
        response.setResult(body);
        return response;
    }

    public static <T> Response<T> getSuccessResponse() {
        final Response<T> response = new Response<>();
        response.setCode(CodeConstant.Http.SUCCESS);
        response.setMsg("操作成功！");
        response.setResult(null);
        return response;
    }

    public static <T> Response<T> getResponse(Integer code, String msg, T body) {
        final Response<T> response = new Response<>();
        response.setCode(code);
        response.setMsg(msg);
        response.setResult(body);
        return response;
    }

}
